package com.ruoyi.project.price.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.price.domain.BinsAccountTrace;
import com.ruoyi.project.price.service.IBinsAccountTraceService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 账户流水Controller
 * 
 * @author administrator
 * @date 2025-04-03
 */
@RestController
@RequestMapping("/price/trace")
public class BinsAccountTraceController extends BaseController
{
    @Autowired
    private IBinsAccountTraceService binsAccountTraceService;

    /**
     * 查询账户流水列表
     */
    @PreAuthorize("@ss.hasPermi('price:trace:list')")
    @GetMapping("/list")
    public TableDataInfo list(BinsAccountTrace binsAccountTrace)
    {
        startPage();
        List<BinsAccountTrace> list = binsAccountTraceService.selectBinsAccountTraceList(binsAccountTrace);
        return getDataTable(list);
    }

    /**
     * 导出账户流水列表
     */
    @PreAuthorize("@ss.hasPermi('price:trace:export')")
    @Log(title = "账户流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BinsAccountTrace binsAccountTrace)
    {
        List<BinsAccountTrace> list = binsAccountTraceService.selectBinsAccountTraceList(binsAccountTrace);
        ExcelUtil<BinsAccountTrace> util = new ExcelUtil<BinsAccountTrace>(BinsAccountTrace.class);
        util.exportExcel(response, list, "账户流水数据");
    }

    /**
     * 获取账户流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('price:trace:query')")
    @GetMapping(value = "/{traceSn}")
    public AjaxResult getInfo(@PathVariable("traceSn") String traceSn)
    {
        return success(binsAccountTraceService.selectBinsAccountTraceByTraceSn(traceSn));
    }

    /**
     * 新增账户流水
     */
    @PreAuthorize("@ss.hasPermi('price:trace:add')")
    @Log(title = "账户流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BinsAccountTrace binsAccountTrace)
    {
        return toAjax(binsAccountTraceService.insertBinsAccountTrace(binsAccountTrace));
    }

    /**
     * 修改账户流水
     */
    @PreAuthorize("@ss.hasPermi('price:trace:edit')")
    @Log(title = "账户流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BinsAccountTrace binsAccountTrace)
    {
        return toAjax(binsAccountTraceService.updateBinsAccountTrace(binsAccountTrace));
    }

    /**
     * 删除账户流水
     */
    @PreAuthorize("@ss.hasPermi('price:trace:remove')")
    @Log(title = "账户流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{traceSns}")
    public AjaxResult remove(@PathVariable String[] traceSns)
    {
        return toAjax(binsAccountTraceService.deleteBinsAccountTraceByTraceSns(traceSns));
    }
}
